package com.jianglin.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jianglin.mapper.RepairtypeMapper;
import com.jianglin.model.Repairtype;
import com.jianglin.service.IRepairtypeService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RepairtypeServiceImpl implements IRepairtypeService {

    private final RepairtypeMapper repairtypeMapper;

    public RepairtypeServiceImpl(RepairtypeMapper repairtypeMapper) {
        this.repairtypeMapper = repairtypeMapper;
    }

    @Override
    public PageInfo<Repairtype> findListByPage(Integer page, Integer pageCount) {
        PageHelper.startPage(page, pageCount);
        List<Repairtype> list = repairtypeMapper.findAll();
        return new PageInfo<>(list);
    }

    @Override
    public List<Repairtype> findList() {
        return repairtypeMapper.findAll();
    }

    @Override
    public int add(Repairtype repairtype) {
        return repairtypeMapper.insert(repairtype);
    }

    @Override
    public int delete(Long id) {
        return repairtypeMapper.delete(id);
    }

    @Override
    public int updateData(Repairtype repairtype) {
        return repairtypeMapper.update(repairtype);
    }

    @Override
    public Repairtype findById(Long id) {
        return repairtypeMapper.findById(id);
    }
}
